<?php 
$this->load->view('admin/layout/head', array('title'=>"货损管理",'nav'=>'order'), FALSE);
switch ($this->session->admin_language) {
	case 'chinese':
		$prefix = '';
		break;
	case 'english':
		$prefix = 'en_';
		break;
	default:
		$prefix = '';
		break;
}

?>

<div id="container">
<ul class="nav nav-tabs" id="subject-tab">
	<li class="active"><a href="javascript:;">创建货损记录</a></li>
</ul>
<form method="post" class="form-inline deal-from container-fluid no-padding" id="product-form">
	<div class="mt-20">
		<label for="">选择商品</label>
		<div class="form-group dropdown">
			<input type="text" name="code" value="" autocomplete="false" placeholder="请输入或扫描条形码内容" class="form-control">
		</div>
	</div>
	
	<div class="mt-20">
		<label for="">货损类型</label>
		<div class="form-group">
			<select name="type" class="form-control">
				<option value="0">货损</option>
				<option value="1">过期</option>
			</select>
		</div>
	</div>
	<div class="mt-20">
		<label for="">货损数量</label>
		<div class="form-group">
			<input type="number" name="qty" value="" class="form-control"/>
		</div>
	</div>

	<div style="padding-left:110px" class="mt-20">
      <a href="javascript:;" class="btn btn-primary save">保存</a>
      <a href="javascript:;" onclick="window.history.go(-1);" class="btn btn-default cancel"><?= $this->lang->line('cancel') ?></a>
    </div>

	
</form>
</div>


<?php 
$this->load->view('admin/layout/footer');
?>
<script type="text/javascript">
$(function(){
	$('.save').on('click',function(){
		if(!$('input[name=code]').val()){
			Toast.error('请输入商品条形码内容');
			return;
		}
		if(!$('input[name=qty]').val()){
			Toast.error('请输入货损数量');
			return;
		}
		$.post('/admin/damage/create', $('#product-form').serialize(), function(data, textStatus, xhr) {
			var json = $.parseJSON(data);
			if(json.code == 0){
				Toast.success('添加成功！');
				window.history.go(-1);
			}else{
				Toast.error(json.msg);
			}
		});
	})
})
</script>